﻿/*
 * Created by SharpDevelop.
 * User: bcrawford
 * Date: 4/4/2013
 * Time: 9:04 AM
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Drawing;
using System.Windows.Forms;

namespace Workbench
{
	/// <summary>
	/// Description of WorkbenchOptions.
	/// </summary>
	public partial class WorkbenchOptions : Form
	{
		private ToolTip TipforExpansion;
		private ToolTip TipforGroundup;
		private ToolTip TipforRemodel;
		private ToolTip TipforTakeOver;
		public delegate void ProjectTypeChangedHandler(Contacts.ProjectTypes ProjectType);
		public event ProjectTypeChangedHandler ProjectTypeChanged;
		public WorkbenchOptions()
		{

			//
			// The InitializeComponent() call is required for Windows Forms designer support.
			//
			InitializeComponent();
			
			#region ToolTips
			TipforExpansion = new ToolTip ();
			TipforExpansion.AutoPopDelay = 500;
			TipforExpansion .InitialDelay = 100;
			TipforExpansion.ReshowDelay = 500;
			TipforExpansion.ShowAlways = true;
			TipforExpansion.SetToolTip (this.Expansion, "Select to disply Expansion Jobs");
			
			TipforGroundup = new ToolTip ();
			TipforGroundup.AutoPopDelay = 500;
			TipforGroundup .InitialDelay = 100;
			TipforGroundup.ReshowDelay = 500;
			TipforGroundup.ShowAlways = true;
			TipforGroundup.SetToolTip (this.GroundUp, "Select to disply New Ground Up Jobs");
			
			TipforRemodel = new ToolTip ();
			TipforRemodel.AutoPopDelay = 500;
			TipforRemodel .InitialDelay = 100;
			TipforRemodel.ReshowDelay = 500;
			TipforRemodel.ShowAlways = true;
			TipforRemodel.SetToolTip (this.Remodel, "Select to disply Remodel Jobs");
			
			TipforTakeOver = new ToolTip ();
			TipforTakeOver.AutoPopDelay = 500;
			TipforTakeOver .InitialDelay = 100;
			TipforTakeOver.ReshowDelay = 500;
			TipforTakeOver.ShowAlways = true;
			TipforTakeOver.SetToolTip (this.TakeOver, "Select to disply Take Over Jobs");
			#endregion
			
		}

		public Contacts.JobFilter GetJobsFilter { 
		  get {
		    if (ActiveJobsBox.Checked) return Contacts.JobFilter.Current;
		    else return Contacts.JobFilter.All;
		  }
		}
		    
		/// <summary>
		/// Establish default values based on the current user settings.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		void WorkbenchOptionsLoad(object sender, EventArgs e)
		{
			Expansion.Checked = Workbench.Properties.Settings.Default.EXPANSION;
			TakeOver.Checked = Workbench.Properties.Settings.Default.TAKEOVER;
			GroundUp.Checked = Workbench.Properties.Settings.Default.GROUNDUP;
			Remodel.Checked = Workbench.Properties.Settings.Default.REMODEL;
			RMCbox.Checked = Workbench.Properties.Settings.Default.REMODELC;
			fixturing.Checked = Workbench.Properties.Settings.Default.FIXTURE;
			tenant.Checked = Workbench.Properties.Settings.Default.TENANT;
			special.Checked = Workbench.Properties.Settings.Default.SPECIAL;
			OsrBox.Checked = Workbench.Properties.Settings.Default.OSR;
			ReloBox.Checked = Workbench.Properties.Settings.Default.RELO;
			landbanked.Checked = Workbench.Properties.Settings.Default.LANDBANK;
			AllJobsBox.Checked = Workbench.Properties.Settings.Default.ALLJOBS;
			ActiveJobsBox.Checked = Workbench.Properties.Settings.Default.CURRENTJOBS;
			
			this.fixturing.CheckedChanged += new System.EventHandler(this.FixturingCheckedChanged);
			this.special.CheckedChanged += new System.EventHandler(this.SpecialCheckedChanged);
			this.tenant.CheckedChanged += new System.EventHandler(this.TenantCheckedChanged);
			this.RMCbox.CheckedChanged += new System.EventHandler(this.RMCboxCheckedChanged);
			this.landbanked.CheckedChanged += new System.EventHandler(this.LandbankedCheckedChanged);
			this.ReloBox.CheckedChanged += new System.EventHandler(this.ReloBoxCheckedChanged);
			this.OsrBox.CheckedChanged += new System.EventHandler(this.OsrBoxCheckedChanged);
			this.TakeOver.CheckedChanged += new System.EventHandler(this.TakeOverCheckedChanged);
			this.Remodel.CheckedChanged += new System.EventHandler(this.RemodelCheckedChanged);
			this.GroundUp.CheckedChanged += new System.EventHandler(this.GroundUpCheckedChanged);
			this.Expansion.CheckedChanged += new System.EventHandler(this.ExpansionCheckedChanged);
			this.AllJobsBox.CheckedChanged += new System.EventHandler(this.AllJobsBoxCheckedChanged);
			this.ActiveJobsBox.CheckedChanged += new System.EventHandler(this.ActiveJobsBoxCheckedChanged);
			
		}
		
		void ExpansionCheckedChanged (object sender, EventArgs e)
		{
			Workbench.Properties.Settings.Default.EXPANSION = Expansion.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.Expansion);
		}
		
		void GroundUpCheckedChanged (object sender, EventArgs e)
		{
			Workbench.Properties.Settings.Default.GROUNDUP = GroundUp.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.GroundUp);
		}
		
		void RemodelCheckedChanged (object sender, EventArgs e)
		{
			Workbench.Properties.Settings.Default.REMODEL = Remodel.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.Remodel);
		}
		
		void TakeOverCheckedChanged (object sender, EventArgs e)
		{
			Workbench.Properties.Settings.Default.TAKEOVER = TakeOver.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.TakeOver);
		}
		
		void OsrBoxCheckedChanged(object sender, EventArgs e)
		{
			Workbench.Properties.Settings.Default.OSR = OsrBox.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.OnSiteRelo);
		}
		
		void ReloBoxCheckedChanged(object sender, EventArgs e)
		{
					Workbench.Properties.Settings.Default.RELO = ReloBox.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.Relo);
		}
		
		void LandbankedCheckedChanged(object sender, EventArgs e)
		{
						Workbench.Properties.Settings.Default.LANDBANK = landbanked.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.LandBank);
		}
		
		void RMCboxCheckedChanged(object sender, EventArgs e)
		{
						Workbench.Properties.Settings.Default.REMODELC = RMCbox.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.RemodelC);
		}
		
		void TenantCheckedChanged(object sender, EventArgs e)
		{
						Workbench.Properties.Settings.Default.TENANT = tenant.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.Tenant);
		}
		
		void SpecialCheckedChanged(object sender, EventArgs e)
		{
						Workbench.Properties.Settings.Default.SPECIAL = special.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.Special);
		}
		
		void FixturingCheckedChanged(object sender, EventArgs e)
		{
						Workbench.Properties.Settings.Default.FIXTURE = fixturing.Checked;
			Workbench.Properties.Settings.Default.Save ();
			if (ProjectTypeChanged != null)
				ProjectTypeChanged (Contacts.ProjectTypes.Fixturing);
		}
		
		void ActiveJobsBoxCheckedChanged(object sender, EventArgs e)
		{
		  Workbench.Properties.Settings.Default.CURRENTJOBS = ActiveJobsBox.Checked;
		  Workbench.Properties.Settings.Default.ALLJOBS = !ActiveJobsBox.Checked;
		  AllJobsBox.Checked = !ActiveJobsBox.Checked;
		  Workbench.Properties.Settings.Default.Save();
		}
		
		void AllJobsBoxCheckedChanged(object sender, EventArgs e)
		{
		  Workbench.Properties.Settings.Default.ALLJOBS = AllJobsBox.Checked;
		  Workbench.Properties.Settings.Default.CURRENTJOBS = !AllJobsBox.Checked;
		  ActiveJobsBox.Checked = !AllJobsBox.Checked;
		  Workbench.Properties.Settings.Default.Save();
		}
	}
}
